package com.tianjin.design.prototype;

import java.util.HashMap;

public class ShapeCache {

	private static HashMap<String, Shape> SHAPE_MAP = new HashMap<String, Shape>();
	
	public static Shape getShape(String shapeId) {
		Shape shape = SHAPE_MAP.get(shapeId);
		return (Shape) shape.clone();
	}
	
	// 初始化数据
	public static void loadCache() {
		
		Square square = new Square();
		square.setId("1");
		SHAPE_MAP.put(square.getId(), square);
		
		Circle circle = new Circle();
		circle.setId("2");
		SHAPE_MAP.put(circle.getId(), circle);
	}
}
